<template>
	<!-- 商品标签 -->
	<view class="goods-label-fixed c-white" v-if="goodsInfo && goodsInfo.label1">
		<image class="img-68-30" :src="$fullLink(goodsInfo.label1.icon)" mode="aspectFit" v-if="goodsInfo.label1.icon"></image>
		<view class="e-p-l-10 e-p-r-10 e-radius-4" :style="{backgroundColor:goodsInfo.label1.colour}" v-else>
			{{goodsInfo.label1.name}}
		</view>
	</view>
	
</template>

<script>
	export default {
		props: {
			info: Object
		},
		data() {
			return {
				goodsInfo: null
			}
		},
		watch: {
			info: {
				handler(val) {
					if (val.activity) {

						this.goodsInfo = JSON.parse(JSON.stringify(val.activity))

						if (this.goodsInfo.label) {
							this.goodsInfo.label = JSON.parse(this.goodsInfo.label)
							this.goodsInfo.label1 = this.goodsInfo.label[0]
							if (this.goodsInfo.label.length > 1) {
								this.goodsInfo.label2 = this.goodsInfo.label.filter((item, index) => index != 0)
							}
						}
					}
				},
				deep: true,
				immediate: true
			}
		}
	}
</script>

<style lang="scss" scoped>
	.goods-label-fixed {
		position: absolute;
		top: 20rpx;
		right: 20rpx;
	}
	.img-68-30 {
		width: 68rpx;
		height: 30rpx;
	}
</style>
